package com.zhongke.cotrun.mapper;

import com.zhongke.cotrun.model.pojo.MembershipValues;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface MembershipValuesMapper {
    /**
     * 批量批量插入积分值和积分对应的规则
     *
     * @param membershipValues
     * @return
     */
    public boolean insertListMemberShipValues(List<MembershipValues> membershipValues);

    /**
     * 根据所属规则的id用户等级，用户类型返回所有的积分对应的值
     *
     * @param ofIntegralRecordId
     * @return
     */
    @Select("SELECT * FROM membership_values WHERE of_integral_recordId=#{ofIntegralRecordId} AND membership=#{membership} AND user_type like '%${userType}%'")
    public MembershipValues selectOfMembershipValue(@Param("ofIntegralRecordId") Integer ofIntegralRecordId, @Param("membership") String membership, @Param("userType") String userType);

    /***
     * 根据所属积分规则id查询积分规则所属id的值
     * @param IntegralRecordId
     * @return
     */
    @Select("SELECT * FROM membership_values WHERE of_integral_recordId=#{ofIntegralRecordId}")
    public List<MembershipValues> selectAllMembershipValuesByOfIntegralRecordId(Integer IntegralRecordId);

    /**
     * 批量更新积分规则所属积分
     * @param membershipValues
     * @return
     */

    public  boolean updateMembershipValues(List<MembershipValues> membershipValues);

    /***
     *根据所属积分规则的id删除积分规则的值
     * @param ofIntegralRecordId
     * @return
     */
    @Delete("DELETE FROM membership_values WHERE of_integral_recordId=#{ ofIntegralRecordId}")
    public  boolean deleteMembershipValuesByIntegralRecordId(Integer ofIntegralRecordId);

}
